package com.kool.kadmin.system.controller;

import com.kool.kadmin.common.bean.PageListResult;
import com.kool.kadmin.common.bean.Result;
import com.kool.kadmin.common.util.ResultUtil;
import com.kool.kadmin.system.request.GetMyNotifyPageReq;
import com.kool.kadmin.system.request.SendMsgReq;
import com.kool.kadmin.system.request.SetOneReadReq;
import com.kool.kadmin.system.service.NotifyService;
import com.kool.kadmin.system.vo.NotifyVo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author luyu
 */
@RestController
public class NotifyController {
    @Resource
    private NotifyService notifyService;

    /**
     * 分页查询我的通知消息列表
     *
     * @param request
     * @return
     */
    @RequestMapping("/sys/notify/getMyNotifyPage")
    public PageListResult<NotifyVo> getMyNotifyPage(@Valid @RequestBody GetMyNotifyPageReq request) {
        return notifyService.getMyNotifyPage(request);
    }

    /**
     * 设置通知消息状态为已读
     *
     * @param request
     */
    @RequestMapping("/sys/notify/setOneRead")
    public Result setOneRead(@Valid @RequestBody SetOneReadReq request) {
        notifyService.setOneRead(request);
        return ResultUtil.success();
    }


    /**
     * 设置所有通知消息状态为已读
     */
    @RequestMapping("/sys/notify/setAllRead")
    public Result setAllRead() {
        notifyService.setAllRead();
        return ResultUtil.success();
    }

    /**
     * 发送消息
     *
     * @param request
     * @return
     */
    @RequestMapping("/sys/notify/sendMsg")
    public Result sendMsg(@Valid @RequestBody SendMsgReq request){
        notifyService.sendMsg(request);
        return ResultUtil.success();
    }
}
